package com.wanxi.iterator;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class ArrayListStudent {
    public static void main(String[] args) {
        List<Student> list = new ArrayList<>();
        list.add(new Student("张三", 11));
        list.add(new Student("李四", 12));
        list.add(new Student("李四", 17));
        list.add(new Student("李四", 17));
        list.add(new Student("王五", 13));
        Student student=new Student("bb",22);
//        List根据索引添加对象时才有的方法 list.add(3,student);
        list.add(3,student);
        for (Student s : list
        ) {
//            s.setName("aaa");
            System.out.println(s);
//            if (s.getName().equals("李四")) {
//                list.remove(s);
//            }
        }
//        for (int i = 0; i < list.size(); i++) {
//            Student next = list.get(i);
//            if (next.getName().equals("李四")) {
//                list.remove(i);
//            }
//        }
//        System.out.println(list);
    }
}
